#include <cstdio>
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;

#define BUF_SIZE 1000
#define STRING_LENGTH 100
#define WORD_LENGTH 100
#define MAX_WORDS 200

int main()
{
    char buf[BUF_SIZE] = {0};
    while (cin.getline(buf, BUF_SIZE)) {
        // printf(">> %s\n", buf);
        char str1[STRING_LENGTH], str2[STRING_LENGTH];
        scanf("%s ", str1);
        scanf("%s ", str2);

        int buf_len = strlen(buf);
        int words_count = 1;
        int words_pos[MAX_WORDS] = {0};
        for (int i = 0; i < buf_len; i++) {
            if (buf[i] == ' ') {
                words_pos[words_count] = i + 1;
                words_count++;
            }
        }
        
        char (*words_list)[WORD_LENGTH] = 
            (char(*)[WORD_LENGTH])malloc(words_count * sizeof(char) * WORD_LENGTH);
        
        for (int i = 0; i < words_count; i++) {
            sscanf(buf + words_pos[i], "%s", words_list[i]);
            if (strcmp(words_list[i], str1) == 0) {
                sscanf(str2, "%s", words_list[i]);
            }
            if (i == words_count - 1)
                printf("%s", words_list[i]);
            else
                printf("%s ", words_list[i]);
        }
        printf("\n");
    }
}